package com.earthea.common.util;

import cn.hutool.system.SystemUtil;
import com.earthea.common.constant.BaseConstants;
import com.google.common.base.Splitter;
import com.google.common.collect.Lists;
import org.apache.commons.lang3.StringUtils;

import java.util.List;

/**
 * 系统工具
 */
public class SystemUtils {

    public static List<String> getListProperty(String key, String separator, List<String> defaultValue) {
        String value = SystemUtil.get(key);
        if (StringUtils.isBlank(value)) {
            return defaultValue;
        }
        return Splitter.on(separator).omitEmptyStrings().trimResults().splitToList(value);
    }

    public static List<String> getListProperty(String key, String separator) {
        return getListProperty(key, separator, Lists.newArrayList());
    }

    public static List<String> getListProperty(String key) {
        return getListProperty(key, BaseConstants.COMMA, Lists.newArrayList());
    }

    public static List<String> getListProperty(String key, List<String> defaultValue) {
        return getListProperty(key, BaseConstants.COMMA, defaultValue);
    }

}
